package experiment11;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class No_2 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        Pane pane=new Pane();

        Circle circle=new Circle(150,150,50);
        circle.setStroke(Color.BLACK);
        circle.setFill(Color.WHITE);

        pane.getChildren().add(circle);

        Scene scene=new Scene(pane,300,300);

        scene.setOnKeyPressed(event -> {
            if (event.getCode().equals(KeyCode.UP)){
                circle.setCenterY(circle.getCenterY()-2);
            }
            if (event.getCode().equals(KeyCode.DOWN)){
                circle.setCenterY(circle.getCenterY()+2);
            }
            if (event.getCode().equals(KeyCode.LEFT)){
                circle.setCenterX(circle.getCenterX()-2);
            }
            if (event.getCode().equals(KeyCode.RIGHT)){
                circle.setCenterX(circle.getCenterX()+2);
            }
        });

        primaryStage.setScene(scene);
        primaryStage.setTitle("circle move");
        primaryStage.show();
    }
}
